'use strict';

//livereload
const watcher = require('glob-watcher');
const livereload = require('gulp-refresh');

const cfgUtil = require('../../app/server/commons/factories/configuration');
const serverCfg = cfgUtil.get('server');

module.exports = function() {
	if (!serverCfg.livereload.disabled) {
		livereload.listen({
			port : serverCfg.livereload.PORT
		});
		watcher('app/client/views/**/*.jade').on('change', function (path) {
			livereload.changed(path);
		});
		watcher('app/client/css/**/*.styl').on('change', function (path) {
			livereload.changed(path);
		});
		watcher('public/js/**/*.js').on('change', function (path) {
			livereload.changed(path);
		});
	}
};
